// The leadone who wants to destory his OI life
/*Mlm:  Tlm:*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mid ((l+r)>>1)
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define ROF(i,a,b) for(int i=(a); i>=(b); --i)
#define modj(x) ((x)-=((x)>=MOD)?MOD:0)
#define min(x,y) (x<y?x:y)
using namespace std;
bool hasinon;
double time1=(double)clock()/CLOCKS_PER_SEC;
//
struct node{
	int x,y,ord;
};
const ll N=8e5,M=20;
vector<node> side[N+10];
int buc[N+10][M+2],tbuc[N+10][M+2],lim[N+10];
int ltot[N+10][M+2],rtot[N+10][M+2];
int fas[N+10],fa[N+10];
ll a[M+2],b[M+2],la[M+2],lb[M+2],ans[N+10];
ll tans=0;
//
inline ll calc(){ ll rt=0;
	ROF(i,M,1) la[i]=la[i+1]+a[i],lb[i]=lb[i+1]+b[i];
	FOR(i,1,M) rt+=(a[i]*lb[i]+b[i]*la[i+1])*(ll)i;
	return rt;
}
void dfs_p(ll ypo,ll po){
	buc[po][M]=1;
	for(auto u:side[po]){
		ll tox=u.x,toy=u.y,tord=u.ord;
		if(tox==ypo) continue;
		fas[tox]=tord; fa[tox]=po; dfs_p(po,tox); 
		memset(a,0,sizeof(a));
		FOR(i,1,M) a[min(1ll*i,toy)]+=buc[tox][i],b[i]=buc[po][i];
		tans+=calc();
		FOR(i,1,M) buc[po][min(1ll*i,toy)]+=buc[tox][i];
	}
}
void dfs(ll ypo,ll po){
	FOR(j,0,M) ltot[0][j]=rtot[(ll)side[po].size()][j]=0;
	FOR(i,0,(ll)side[po].size()-1){
		node u=side[po][i];
		ll tox=u.x,toy=u.y;
		if(tox==ypo){
			FOR(j,1,M) ltot[i+1][j]=ltot[i][j];
			continue;
		} 
		if(i==(ll)side[po].size()-1) continue;
		FOR(j,1,M) ltot[i][min(1ll*j,toy)]+=buc[tox][j];
		FOR(j,1,M) ltot[i+1][j]=ltot[i][j];
	}
	ROF(i,(ll)side[po].size()-1,0){
		node u=side[po][i];
		ll tox=u.x,toy=u.y;
		if(i==0) continue;
		FOR(j,1,M) rtot[i][j]=rtot[i+1][j];
		if(tox==ypo) continue;
		FOR(j,1,M) rtot[i][min(1ll*j,toy)]+=buc[tox][j];
	}
//	printf("LTOT:\n");
//	FOR(i,0,(ll)side[po].size()-1){
//		FOR(j,1,M) printf("%lld ",ltot[i][j]);
//		printf("\n");
//	}
//	printf("RTOT:\n");
//	FOR(i,0,(ll)side[po].size()-1){
//		FOR(j,1,M) printf("%lld ",rtot[i][j]);
//		printf("\n");
//	}
	FOR(i,0,(ll)side[po].size()-1){
		node u=side[po][i];
		ll tox=u.x,toy=u.y;
		if(tox==ypo) continue;
//		printf("TOX:%lld\n",tox);
		FOR(j,1,M) tbuc[tox][min(1ll*j,toy)]+=tbuc[po][j] ;
		if(i>0){
			FOR(j,1,M) tbuc[tox][min(1ll*j,toy)]+=ltot[i-1][j];	
		}
		if(i<(ll)side[po].size()-1){
			FOR(j,1,M) tbuc[tox][min(1ll*j,toy)]+=rtot[i+1][j];	
		}
		FOR(j,1,M) a[j]=tbuc[tox][j],b[j]=buc[tox][j];
		ans[fas[tox]]-=calc();
		++tbuc[tox][M]; 
	}
	FOR(i,0,(ll)side[po].size()-1){
		node u=side[po][i];
		ll tox=u.x,toy=u.y;
		if(tox==ypo) continue;
		dfs(po,tox);
	}
}
//
inline char gc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline int gt(){
	int t=0,f=0;char v=gc();
	while(!isdigit(v))f|=(v=='-'),v=gc();
	while(isdigit(v))t=(t<<3)+(t<<1)+v-48,v=gc();
	return f?-t:t;
}
inline void wr(ll x){
	if(x<0){x*=-1; putchar('-');}
	if(x>9) wr(x/10);
	putchar(x%10+'0');
	return;
}
bool Hasinon;
void usage() {
	double time2=(double)clock()/CLOCKS_PER_SEC;
	cout<<(&Hasinon-&hasinon)/1024/1024<<" Mb, "<<time2-time1<<" s\n";
}
int main() {
//	usage();
	freopen("tatooine.in","r",stdin);
	freopen("tatooine.out","w",stdout);
	int n=gt();
	FOR(i,1,n-1){
		int x=gt(),y=gt(),c=gt();
		side[x].pb((node){y,c,i});
		side[y].pb((node){x,c,i});
	}
	dfs_p(1,1);
//	printf("%lld\n",tans);
	tbuc[1][M]=1; dfs(1,1);
	FOR(i,1,n-1){
		ans[i]+=tans;
		wr(ans[i]); putchar('\n');
	}
}
/*
  0. Enough array size? Enough array size? Enough array size? Integer overflow?

  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?

  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?

  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?

  4. Do you really understand how to greedy(v.)?

  5. Stop using useless algorithms, learn how to use Binary Search.

  6. Don't use sqrt or sqrtl, use Binary Search.
*/



